﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="/CSS/bootstrap3.3.5/css/bootstrap.css" rel="stylesheet" type="text/css" />
    <link href="/CSS/font-awesome-4.3.0/css/font-awesome.css?v=4.3.0" rel="stylesheet">
    <link href="/CSS/V3/animate.css" rel="stylesheet">
    <link href="/CSS/V3/style.css?v=2.2.0" rel="stylesheet">
    <link href="/CSS/V3/BaseClassV3.css" rel="stylesheet">
    <script src="/Scripts/jquery-1.11.2.min.js"></script>
    <script src="/CSS/bootstrap3.3.5/js/bootstrap.js"></script>
    <script src="/JqueryPlug/V3/jsTree/jstree.min.js"></script>
    <script src="/JqueryPlug/laypage/laypage.js"></script>
    <script src="/Scripts/avalon.js"></script>
    <script src="/Scripts/SZHLCommon.js?jsver=5"></script>
    <style>
        .btn:hover .btndel {
            visibility: visible;
        }

        .btn .btndel {
            visibility: hidden;
        }

        .btndel {
            color: red;
        }
    </style>
    <script>

        var model = avalon.define({
            $id: "APP_NOTE",
            ColumnData: [],
            curTagName: "",
            CommonData: [],
            searchContent: "",
            GetNOTEList: function (tagName) {
                model.curTagName = tagName;
                //已添加的记事本
                $.getJSON('/API/FTAPI.ashx?Action=GETUSERNOTELIST_PAGE', { P1: model.searchContent, P2: model.curTagName, p: 1 }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        model.CommonData = resultData.Result;
                        laypage({
                            cont: 'pageDiv', //容器。值支持id名、原生dom对象，jquery对象。
                            pages: Math.ceil(parseInt(resultData.Result1) * 1.0 / 8), //通过后台拿到的总页数
                            curr: 1, //初始化当前页
                            jump: function (e) { //触发分页后的回调
                                $.getJSON('/API/FTAPI.ashx?Action=GETUSERNOTELIST_PAGE', { P1: model.searchContent, P2: model.curTagName, p: e.curr }, function (resultData) {
                                    model.CommonData = resultData.Result;
                                })
                            }
                        });
                    }
                })
            },
            addNOTE: function () {
                parent.ComFunJS.winviewform("/View/APPBaseView/APP_ADD_WF.html?FormCode=NOTE", "添加数据", "1000", "");
            },
            ViewForm: function (ID) {
                parent.ComFunJS.winviewform("/View/APPBaseView/APP_ADD_WF.html?FormCode=NOTE&pageType=edit&ID=" + ID, "数据编辑", "1000", "");
            },
            DELForm: function (item) {
                parent.ComFunJS.winconfirm("确认要删除“" + item.NoteTitle + "”么", function () { 
                    $.post("/API/FTAPI.ashx?ACTION=DELNOTEBYID", { P1: item.ID }, function (result) {
                        var jsonresult = $.parseJSON(result)
                        if ($.trim(jsonresult.ErrorMsg) == "") {
                            model.CommonData.remove(item);
                            parent.ComFunJS.winsuccess('删除成功');
                        }
                    });
                }, function () { })
            }, DelTag: function (item, event) {
                if (event)
                {
                    event.stopPropagation();
                }
                parent.ComFunJS.winconfirm("确认要删除“" + item.TagName + "”么", function () {  
                    $.post("/API/FTAPI.ashx?ACTION=DELTAGBYID", { P1: item.ID }, function (result) {
                        var jsonresult = $.parseJSON(result)
                        if ($.trim(jsonresult.ErrorMsg) == "") {
                            model.ColumnData.remove(item);
                            alert("操作成功");
                        }
                    });
                }, function () { })
            }
        })

        avalon.ready(function () {
            ComFunJS.initsetajax();
            ComFunJS.initForm();
            //获取记事本分类
            $.getJSON('/API/FTAPI.ashx?Action=GETTAGLIST', { P1: "NOTE" }, function (resultData) {
                if (resultData.ErrorMsg == "") {
                    model.ColumnData = resultData.Result;
                }
            })
            model.GetNOTEList('');
        })
    </script>
</head>
<body class="gray-bg" ms-controller="APP_NOTE">
    <div class="wrapper wrapper-content  animated fadeInRight">
        <div class="row">
            <div class="col-sm-3">
                <div class="ibox float-e-margins">
                    <div class="ibox-content" style="border: 0; border-right: 1px solid #e7eaec;">
                        <div class="file-manager">
                            <div class="hr-line-dashed"></div>
                            <button class="btn btn-primary btn-block" ms-click="addNOTE()">添加记事本</button>
                            <div class="hr-line-dashed"></div>
                            <h5 class="tag-title">分类</h5>
                            <button class="btn  btn-sm " ms-class-1="btn-primary:model.curTagName==''" ms-click="GetNOTEList('')" ms-class-2="btn-white:model.curTagName!=''" style="margin-right:5px;padding: 7px 15px;" type="button">全部</button>
                            <button class="btn  btn-sm " ms-repeat-item="ColumnData" ms-class-1="btn-primary:model.curTagName==item.TagName" ms-click="GetNOTEList(item.TagName)" ms-class-2="btn-white:model.curTagName!=item.TagName" style="margin-right:5px" type="button">{{item.TagName}}&nbsp;<i class='iconfont icon-guanbi btndel' ms-click="DelTag(item,event)"></i></button>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-9">
                <div class="ibox">
                    <div class="box" style="margin-bottom:15px;">
                        <div class="pull-right mail-search">
                            <div class="input-group">
                                <input type="text" class="form-control input-sm" ms-duplex="searchContent" name="search" placeholder="输入记事本标题查询">
                                <div class="input-group-btn">
                                    <button type="submit" class="btn btn-sm btn-primary" ms-click="GetNOTEList('')">
                                        搜索
                                    </button>
                                </div>
                            </div>
                        </div>
                        <h2>
                            记事本
                        </h2>
                        <div class="mail-tools tooltip-demo m-t-md">
                            <div class="btn-group pull-right">
                                <div id="pageDiv"></div>
                            </div>
                            <div class="clearfix"></div>
                        </div>
                    </div>
                    <div class="table-responsive">
                        <table class="table table-striped table-hover">
                            <thead>
                                <tr>
                                    <th>序号</th>
                                    <th>标题</th>
                                    <th>创建时间</th>
                                    <th>最后修改时间</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr ms-repeat-item="CommonData">
                                    <td>{{$index+1}}</td>
                                    <td><a ms-click="ViewForm(item.ID)"><i class="fa fa-pencil"></i> {{item.NoteTitle}} </a></td>
                                    <td>{{item.CRDate|date("yyyy-MM-dd HH:mm")}}</td>
                                    <td>{{item.UPDDate|date("yyyy-MM-dd HH:mm")}}</td>
                                    <td style="width:150px">

                                        <a class=" btn btn-primary btn-xs btntool" ms-click="ViewForm(item.ID)"><i class="fa fa-pencil"></i> 编辑 </a>
                                        <a class="btn btn-danger btn-xs btntool" ms-click="DELForm(item)" style="margin-right:15px"><i class="fa fa-trash-o"></i> 删除 </a>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>

            </div>
        </div>
    </div>
</body>
</html>
